var mongoose = require('mongoose')

var PersonSchema = new mongoose.Schema({
    name: String,
    minm:String,
    gender:String,
    parent:String,
    level:String,
    partner:String,
    child:{
        type:Array,
        default:[]
    },
    desc:String,
    born:String,
    bornT:Number,
    order:Number,
    death:String,
    src: String,  //照片
   },
    { timestamps: true }
);


//statics 给类绑定方法 ==>后面用到的User
PersonSchema.statics = {
    fetch: function (cb) {
        return this
            .find({})
            .sort('meta.updateAt')
            .exec(cb)
    },
    findById: function (id, cb) {
        return this
            .findOne({_id: id})
            .exec(cb)
    }
}

module.exports = PersonSchema